package com.dongwei.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * 写一写几个经典的排序算法
 * Created by mac on 15/10/19.
 */

@RestController
@RequestMapping("/api/sort")
public class SortController extends BaseController{

    @RequestMapping(value = "/bubble")
    @ResponseBody
    public Map<String, Object> bubble(@PathVariable int size){

        int[] sortBefore = new int[size];
        for (int i =0; i<size; i++){
            int min=0;
            int max=100;
            Random random = new Random();
            sortBefore[i] = random.nextInt(max)%(max-min+1) + min;
        }

        Map<String, Object> map = new HashMap<>();
        map.put("sortBefore", sortBefore);
        return map;
    }


}
